<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>查找微信会员</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css" />
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css" />
<script type="text/javascript" src="${jspath }/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<script type="text/javascript" src="${layerPath}/extend/layer.ext.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript"
	src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<script type="text/javascript" src="${jspath}/load_layer.js"></script>
<link rel="stylesheet" type="text/css"
	href="${csspath}/jquery.alerts.css" />

<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>

<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>

<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>
	
<script type="text/javascript">
var myHeight = 0;
$(function() {
	if('${(memberResultsDtoList == null or fn:length(memberResultsDtoList) == 0) and fromSearch == "fromSearch"}'=='true'){
		jAlert("您所查询的手机/车牌不存在", "提示信息");
	}
	//选中后该行高亮
	$('#dataTable tr').bind('click', function() {
		if (window.cur)
			window.cur.style.background = "";
		if (window.cur)
			window.cur.style.fontWeight = "normal";
		this.style.background = "#e8e8e8";
		this.style.fontWeight = "bold";
		window.cur = this;
		$(this).find("td input[type='radio']").attr("checked", true);
		$(this).find("td input[type='radio']").click();
	});
	
	$("#saveAndSubmit")
	.click(
			function() {
				if ($("#mobilePhoneHtxt").val() == "") {
					jAlert('请选择会员后再进行操作！', '提示');
					return;
				}
				$.ajax({
					type : 'POST',
					url : '${webcontext}/crmdp/dealer/member/saveMemberFromWechat',
					async : false,
					data : $('#search_form').serialize(),
					dataType : 'json',
					success : function(data) {
						if(data){
							jAlert("保存成功！", "提示信息",function(){
								parent.location.href = "${webcontext}/crmdp/dealer/member/getMaintainMemberPage";
							});
						}else{
							jAlert("保存失败！", "提示信息");
						}
					}
				});
			});
	$("#submitbtn").click(function() {
		if ($("#mobilePhoneOrCarPlate").val() == "") {
			jAlert('请输入完整车牌或手机号！', '提示');
			return;
		}
		$.ajax({
			type : 'POST',
			url : '${webcontext}/crmdp/dealer/member/checkMaintainMemberPageFromWechat',
			async : false,
			data : $('#search_form').serialize(),
			dataType : 'json',
			success : function(data) {
				if(data){
					jAlert("您所查询的手机/车牌在本门店已存在！", "提示信息");
				}else{
					$('#search_form').submit();
				}
			}
		});
	});
	$("#cancel").click(function(){
		jConfirm("确认取消新建会员操作？","确认提示",function(result){
    		if(result == true)
    		{	
    			parent.location.href="${webcontext}/crmdp/dealer/member/redirectMaintainMemberPage";
    		}
    	});
	});
});
	function search() {
		document.getElementById("search_form").submit();
	}
	
	function rdoChange(id, phone, name, carplate,openId) {
		//查询该会员是否存在套餐
		$("#idHtxt").val(id);
		$("#mobilePhoneHtxt").val(phone);
		$("#memberNameHtxt").val(name);
		$("#carPlateHtxt").val(carplate);
		$("#openId").val(openId);
	}
</script>
</head>
<body>
<!-- content -->
	<div id="content" style="height: 580px;width: 1140px;">
		<!-- wrap -->
		<div id="wrap">
			<!-- search_div -->
			<form:form  class="form-horizontal" id="search_form"
				action="${webcontext}/crmdp/dealer/member/getMaintainMemberPageFromWechat"
				method="post" modelAttribute="dto" >
				<input type="hidden" id="idHtxt" name="memberId">
				<input type="hidden" id="mobilePhoneHtxt" name="mobilePhone">
				<input type="hidden" id="memberNameHtxt" name="memberName">
				<input type="hidden" id="carPlateHtxt" name="carPlate">
				<input type="hidden" id="openId" name="openId">
				<div class="spliter h_10"></div>
				<div class="" style="width:600px;margin-left:40px;">					
					<label  style="width: 110px;margin-top: 0px;display:inline;">手机/车牌：</label>
						<input name="mobilePhoneOrCarPlate" class=" input-sm" id="mobilePhoneOrCarPlate"
							type="text" style="width: 200px;"  value="${queryDto.mobilePhoneOrCarPlate}"/>
					<button type="button" id="submitbtn" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-search" style="color:#FFFFFF"></i>&nbsp;查询</button>
					
				</div>
				<div class="spliter h_10"></div>
				<!-- /search_div -->

				<!-- page_div -->

				<!-- /page_div -->
				<!-- data_div -->
				
				<div id="dataTable" class="data_div">
					<div class="spliter h_10"></div>
					<div style="width: 570px; height: auto; margin-top: 10px;margin-left: 10px;">
						<table id="data_tab" class="table table-hover">
							<thead>
							<tr>
								<th width="10%" height="20" >选择</th>
								<th width="20%" height="20" >手机</th>
								<th width="20%" height="20" >姓名</th>
								<th width="15%" height="20" >车牌</th>
							</tr>
							</thead>
							<tbody>
							<core:if test="${memberResultsDtoList != null or fn:length(memberResultsDtoList) != 0}">
								<core:forEach items="${memberResultsDtoList}"
									var="memberResultsDto">
									<tr>
										<td class="text-left">
										<input type="hidden" name="openId" value="${memberResultsDto.openId}">
										<input type="radio" name="id1"
											id="radio${memberResultsDto.memberId}${memberResultsDto.carPlate}Rad"
											class="select_one" value="${memberResultsDto.openId}"
											onClick="rdoChange('${memberResultsDto.memberId}','${memberResultsDto.mobilePhone}','${memberResultsDto.memberName}','${memberResultsDto.carPlate}','${memberResultsDto.openId}')" /></td>
										<td class="text-left"><input type="hidden"
											name="mobilePhone1" value="${memberResultsDto.mobilePhone}">${memberResultsDto.mobilePhone}</td>
										<td class="text-left"><input type="hidden"
											name="memberName1" value="${memberResultsDto.memberName}">${memberResultsDto.memberName}</td>
										<td class="text-left"><input type="hidden" name="carPlate1"
											value="${memberResultsDto.carPlate}">${memberResultsDto.carPlate}</td>
									</tr>
								</core:forEach>
							</core:if>
							<core:if test="">
<!-- 								<font style="color: green;">您所查询的手机/车牌在本门店不存在</font> -->
							</core:if>
							</tbody>
						</table>
						<div class="page_div">
							<%@include file="../common/page.jsp"%>
						</div>
					</div>
					<div class="spliter h_10"></div>
					<button type="button" class="btn btn-success btn-sm" id="saveAndSubmit" style="width: 100px;margin-left: 10px;">
						<i class="glyphicon glyphicon-ok" style="color: #FFFFFF"></i>确认
					</button>
					<button type="button" class="btn btn-success btn-sm" style="width: 100px;" value="取消"
						id="cancel">
						<i class="glyphicon glyphicon-share-alt" style="color: #FFFFFF"></i>&nbsp;取消
					</button>
				</div>
				<!-- /data_div -->
				<!-- page_div -->
				<!-- /page_div -->
			</form:form>
		</div>
		<!-- /wrap -->
	</div>
	<!-- /content -->
</body>
</html>